from selenium import webdriver
from selenium.webdriver.common.by import By
# 实例化驱动
driver = webdriver.Chrome()
# 打开页面
driver.get("https://www.126.com/")
#设置隐式等待
driver.implicitly_wait(15)
# 跳进iframe框架做操作
# 先定位到iframe
iframe = driver.find_elements(By.TAG_NAME,"iframe")[0]
driver.switch_to.frame(iframe)

# 账号
driver.find_element(By.NAME,"email").send_keys("baijiacheng_123")
# 密码
driver.find_element(By.NAME,"password").send_keys("qwe123..")
# 登录按钮
driver.find_element(By.ID,"dologin").click()

# 回到默认的上下文
driver.switch_to.default_content()